﻿#pragma once

#include "../MirEnvir/Envir.h"
#include "CharacterInfo.h"
#include "../../Shared/Data/ItemData.h"
#include "../MirNetwork/MirConnection.h"
#include "AuctionInfo.h"
#include "../../Shared/ClientPackets.h"
#include "../../Shared/Data/SharedData.h"
#include <string>
#include <vector>
#include <list>

using namespace Server::MirNetwork;
using namespace Server::MirEnvir;
namespace C = ClientPackets;

namespace Server::MirDatabase
{
    class AccountInfo
    {
    public:
        virtual ~AccountInfo()
        {
            delete Connection;
        }

    protected:
        static Server::MirEnvir::Envir *getEnvir();

    public:
        int Index = 0;

        std::string AccountID = std::string::Empty;
        std::string Password = std::string::Empty;

        std::string UserName = std::string::Empty;
        DateTime BirthDate;
        std::string SecretQuestion = std::string::Empty;
        std::string SecretAnswer = std::string::Empty;
        std::string EMailAddress = std::string::Empty;

        std::string CreationIP = std::string::Empty;
        DateTime CreationDate;

        bool Banned = false;
        std::string BanReason = std::string::Empty;
        DateTime ExpiryDate;
        int WrongPasswordCount = 0;

        std::string LastIP = std::string::Empty;
        DateTime LastDate;

        std::vector<CharacterInfo*> Characters = std::vector<CharacterInfo*>();

        std::vector<UserItem*> Storage = std::vector<UserItem*>(80);
        bool HasExpandedStorage = false;
        DateTime ExpandedStorageExpiryDate;
        unsigned int Gold = 0;
        unsigned int Credit = 0;

        MirConnection *Connection;

        std::list<AuctionInfo*> Auctions = std::list<AuctionInfo*>();
        bool AdminAccount = false;

        AccountInfo();

        AccountInfo(C::NewAccount *p);
        AccountInfo(BinaryReader *reader);


        void Save(BinaryWriter *writer);

        std::vector<SelectInfo*> GetSelectInfo();

        int ExpandStorage();
    };
}
